const babelCore = require('@babel/core')

const code = `
    obj.foo = "isValid";

    obj.const = "isKeyword";
    obj["var"] = "isKeyword";
`

const result = babelCore.transformSync(code, { plugins: ["@babel/plugin-transform-member-expression-literals"]})

console.log(result.code);